package cn.adminsys.web.controller;


import cn.adminsys.web.domain.R;
import cn.adminsys.web.utils.AliyunOssStsUtil;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.util.StreamUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping(value = "/")
public class ApiController {

    /**
     * 获取阿里云OSS上传临时凭证
     * @return
     */
    @GetMapping( "/alioss/sts/token")
    public R<AliyunOssStsUtil.StsCredentials> getAliOssStsAccessToken() {
        AliyunOssStsUtil.StsCredentials result = AliyunOssStsUtil.getStsAccessToken();
        if(result == null){
            return R.fail("获取临时凭证失败");
        }
        return R.ok(result);
    }

}
